package Application.Controller;

import Application.entity.Customer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

@RestController
public class SearchController {
    @Value("${server.port}")
    private  String port;
    @GetMapping("/search")
    public String search(){
//        int i=1/0;
        return "search"+port;
    }

    @GetMapping(value = "/search/{id}")
    public Customer searchById(@PathVariable Integer id){
        return new Customer("郑树凯", 1, (int)(Math.random()*1000));
    }

    @GetMapping(value = "/getCustomer")
    public  Customer getCustomer(@RequestParam Integer id,@RequestParam String name){
        return new Customer(name,id,21);
    }
    @PostMapping(value = "/save")
    public  Customer save(@RequestBody Customer customer){
        return customer;
    }
}

